package com.slt.android.customview;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;


/**
 * Created by dp on 2017/12/14.
 */

public class CustomViewDraw extends View {


    Bitmap bitmap , bitmap1 , bitmap2 ;
    public CustomViewDraw(Context context) {
        super(context);
        init(context);
    }

    public CustomViewDraw(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public CustomViewDraw(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        bitmap = BitmapFactory.decodeResource(getResources() , R.mipmap.bitmap).copy(Bitmap.Config.ARGB_8888, true);
        bitmap1 = BitmapFactory.decodeResource(getResources() , R.mipmap.ic_launcher).copy(Bitmap.Config.ARGB_8888, true);
        bitmap2 = BitmapFactory.decodeResource(getResources() , R.mipmap.ic_launcher_round).copy(Bitmap.Config.ARGB_8888, true);

        MyApplication.mCanvas = new Canvas(bitmap2);
//        mCanvas.drawColor(Color.GRAY);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawBitmap(bitmap1 , 0 , 0 , null);
        canvas.drawBitmap(bitmap2 , 180 , 0 , null);
    }
}
